# -*- encoding=utf8 -*-
import unittest
from parameterized import parameterized

from api.login_api import loginApi
from common.assertUtill import assertUtill
from common.load_json import load_jsona
from config import BASE_DIR


class loginTest(unittest.TestCase):
    path = BASE_DIR + '/data/login_data.json'

    @classmethod
    def setUpClass(cls) -> None:
        resp = loginApi.login("1008611","25166186","aa123321")
        # assertUtill(cls, resp.json(), "0", "success")

        cls.token = resp.json()['result']['userList'][0]['accesstoken']
        cls.userID = resp.json()['result']['userList'][0]['userID']


    @parameterized.expand(load_jsona(path))
    def test01(self,desc,req_data,code,statu):

        resp = loginApi.login(req_data['parameter']['systemID'], req_data['parameter']['schoolID'], req_data['parameter']['pwd'])

        assertUtill(self, resp.json(), code, statu)

